<?php
if(!defined('DCS_ROOT')) {exit('Access Denied');} 
class login {
	function defaultAction (){
		if(isPost()) {
			$username =  $_POST["username"];
			$password =  $_POST["password"];
			if(preg_match('/^.+$/',$username) and  preg_match('/^.+$/',$password)){
				require_once(APP_PATH."Model/Admin/User.php" );
				$DB  = getDB();
				$data	=  new User( $DB );
				$login	= $data->Logins($username,$password);
				global $timestamp,$onlineip;
				if ($login){
					message('','/admin/');
				}else{
					message('Username or password Error.');	
				}
			}else{				
				message('Please enter your username or password.');
			}
			$tpl = new Template("admin/main/login.htm");
			$tpl->output();
		}else{
			$url = getUrl();
			$tpl = new Template("admin/main/login.htm");
			$tpl->assign("reUrl", $url['action']);
			$tpl->output();
		}
	}

}

?>

